<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var date1 = new Date();//穿件Date对象

    var year = date1.getFullYear();//获取当前年份

    console.log(year);

    var month = date1.getMonth();//获取月份 范围0-11  需要加1

    console.log(month + 1);

    var time = date1.toDateString();//获取当前日期

    console.log(time);

    var weekday = date1.getDay();//获取周  每个星期的第一天是星期日  索引范围是0-6

    console.log(weekday);

    var  weeks = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
    var weekday = date1.getDay();
    console.log(weeks[weekday]);

    var day = date1.getDate();//获取当前日期
    console.log(day);

    var hour = date1.getHours();
    var minute = date1.getMinutes();
    var second = date1.getSeconds();

    console.log(hour + ":" + minute + ":" + second);
</script>
</html>